function close_attribute_parent_id(file_id,objname,parent_id)
% closes the type of object off of which the attribute hangs.

v = version('-release');
switch(v)
    case { '2006b', '2007a', '2007b', '2008a', '2008b', '2009a' }
	    statbuf=H5G.get_objinfo (file_id, objname,0);
		switch (statbuf.type) 
			case H5ML.get_constant_value('H5G_GROUP')
            	H5G.close(parent_id);
		    case H5ML.get_constant_value('H5G_DATASET')
            	H5D.close(parent_id);
		    case H5ML.get_constant_value('H5G_DATATYPE')
            	H5T.close(parent_id);
		    otherwise
				error('HDF5TOOLS:h5attput:unhandledObjectType', ...
				      '%s is not a group, dataset, or datatype.', objname);
		end

    otherwise
		H5O.close(parent_id);
end
